def a():
    # Read the entire file as a single string
    with open('somefile.txt', 'rt') as f:
        data = f.read()

    # Iterate over the lines of the file
    with open('somefile.txt', 'rt', encoding='utf-8') as f:
        for line in f:
            # process line
            pass


# 重写
with open('somefile.txt', 'w') as f:
    f.write('1223\n')
    f.write('22234')

with open('somefile.txt', 'w') as f:
    print('1111', file=f)
    print('2222', file=f)

# 追加
with open('somefile.txt', 'a') as f:
    f.write('3333')




